<h1>Liste des Incidents</h1>
<br /><br />
<% if authenticated? %>
  <%= link_to 'Créer un incident', new_incident_path %>
<% end %>
<br /><br />
<% if @incidents.empty? %>
  <h3>Aucun Incident</h3>
<% else %>
  <% form_tag({:controller => "incidents", :action => "recherche"}, {:name => "form_id"}) do %>
    <%= radio_button_tag "tri", "datedetection" %> Date de détection
    <%= radio_button_tag "tri", "dateresolution" %> Date de résolution
    <%= radio_button_tag "tri", "typeincident" %> Type d'incident
    <br /><br />
    <%= select_tag "etat", options_for_select(@etat.insert(0, ["Tout état",""]), "") %><br /><br />
    <%= submit_tag "Rechercher" %>
  <% end %>
  <br /><br />
  <table cellspacing="0" style="width: 100%;">
    <tr style="background-color: #0099FF;">
      <th>Type d'Incident</th>
      <th>Date de Détection</th>
      <th>Date de Résolution</th>
      <th>Etat</th>
      <th>Machine</th>
      <th>Propriété Complémentaire</th>
      <th style="width: 10%;">Actions</th>
    </tr>
    <% @incidents.each do |incident| %>
      <tr>
        <td><%=h libelle(incident.typeincident) %></td>
        <td><%=h incident.datedetection.strftime('%d-%m-%Y') if !incident.datedetection.nil? %></td>
        <td><%=h incident.dateresolution.strftime('%d-%m-%Y') if !incident.dateresolution.nil? %></td>
        <td><%=h incident.etat %></td>
        <td><%=h incident.nommachine %></td>
        <td><%=h incident.proprietecomple %></td>
        <td><%= link_to image_tag("voir.png", :alt => "Voir"), incident %>
		<% if authenticated? %>
			<%= link_to image_tag("edit.png", :alt => "Modifier"), edit_incident_path(incident) %>
			<%= link_to image_tag("supp.png", :alt => "Supprimer"), incident, :confirm => 'Etes-vous sûr?', :method => :delete %></td>
		<% end %>
      </tr>
    <% end %>
<% end %>
</table>